<template>
    <div class="notice-detail">
        <div class="headTitle">{{title}}</div>
        <div class="notice-container" v-html="htmlContent"></div>
    </div>
</template>

<script setup>
import { useRoute } from 'vue-router'
import request from '@/utils/request'
import { ref } from 'vue'

const route = useRoute()
const htmlContent = ref('')
const title = ref('')
const load = () => {
    request.get(`/notice/${route.params.id}`)
        .then(res => {
            htmlContent.value = res.data?.contentHtml || '<p>暂无内容</p>'
            title.value = res.data?.title || ''
        })
        .catch(err => {
            console.error(err)
            htmlContent.value = '<p>加载失败，请稍后重试</p>'
        })
}
load()
</script>
<style scoped>

.headTitle{
    text-align: center;
    margin: 5px 0  30px  0;
    color: #000000;
    font-size: 40px;
}
.notice-detail {
    max-width: 900px;
    margin: 40px auto;
    padding: 24px;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 0 8px rgba(0, 0, 0, 0.05);
    font-family: 'Helvetica Neue', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.notice-container {
    line-height: 1.8;
    color: #333;
    font-size: 16px;
}

.notice-container h1,
.notice-container h2,
.notice-container h3 {
    margin: 24px 0 12px;
    font-weight: bold;
    color: #222;
}

.notice-container p {
    margin: 12px 0;
}

.notice-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 16px auto;
    border-radius: 4px;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
}

.notice-container table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.notice-container table,
.notice-container th,
.notice-container td {
    border: 1px solid #ccc;
}

.notice-container th,
.notice-container td {
    padding: 8px;
    text-align: left;
}
</style>